<template>
    <el-dialog
    :title="'通知详情'"
    :close-on-click-modal="false"
    :visible.sync="visible">
    <el-form :model="dataForm" ref="dataForm" label-width="100px">
      <el-form-item label="标题" prop="title">
        <span>{{dataForm.title}}</span>
      </el-form-item>
      <el-form-item label="通知内容" prop="content">
        <span>{{dataForm.content}}</span>
      </el-form-item>
      <el-form-item label="发布时间" prop="createTime">
        <span>{{dateFormat(dataForm.createTime,'YYYY/MM/DD hh:mm')}}</span>
      </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">关闭</el-button>
    </span>
  </el-dialog>
</template>

<script>
  export default {
    data () {
      return {
        visible: false,
        disabled: false,
        dataForm: {
          id: null,
          title: null,
          content: null,
          orderNum: 1,
          createTime: null
        }
      }
    },
    methods: {
      init (id) {
        this.dataForm.id = id || null;
        this.visible = true
        this.$nextTick(() => {
          this.$refs['dataForm'].resetFields();
          if (this.dataForm.id) {
            this.$http({
              url: this.$http.adornUrl(`/sys/notice/detail/${this.dataForm.id}`),
              method: 'get',
              params: this.$http.adornParams()
            }).then(({data}) => {
              if (data && data.code === 0) {
                this.dataForm.title = data.item.title;
                this.dataForm.content = data.item.content;
                this.dataForm.orderNum = data.item.orderNum;
                this.dataForm.createTime = data.item.createTime;
              }
            })
          }
        })
      }
    }
  }
</script>
